#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <inttypes.h>

typedef int64_t num_t;
#define num_sch SCNd64
#define num_pph PRId64

int logic(num_t number) {
    if (number <= 2) {
        return 0;
    }
    num_t now = 2;
    int count = 0;
    int all_cnt = 0;
    while (number != 1 || count != 0) {
        if (number % now != 0 || (number == 1 && count != 0)) {
            if (count != 0) {
                if (count > 1) {
                    return 0;
                } else {
                    all_cnt++;
                    if (all_cnt == 2) {
                        return number == 1;
                    }
                }
            } else {
                if (now * now >= number) {
                    return all_cnt == 1;
                    break;
                }
            }
            count = 0;
            now++;
        } else {
            number /= now;
            count++;
        }
    }
    assert(0);
}

int main(void) {
    int k;
    scanf("%d", &k);
    for(int i = 0; i < k; i++) {
        num_t number;
        scanf("%" num_sch, &number);
        puts(logic(number) ? "Yes" : "No");
    }
    return 0;
}
